#ifndef __ROBOT_H__
#define __ROBOT_H__

#include "main.h"

#define int8_t signed char
#define int16_t signed short int
#define int32_t signed long
#define uint8_t unsigned char
#define uint16_t unsigned short int
#define uint32_t unsigned long

typedef enum motor_name{
    MOTOR_M1,
    MOTOR_M2,
    MOTOR_M3,
    MOTOR_M4,
    MOTOR_E1,
    MOTOR_E2,
    MOTOR_MAX_NUM,
} motor_name_e;

typedef void (*motor_sign_write_func)(motor_name_e motor_num, uint8_t sign);

typedef enum motor_mode {
    MOTOR_STOP_MODE,
    MOTOR_MANUAL_MODE,
    MOTOR_AUTO_MODE,
    MOTOR_KEEP_MODE,
} motor_mode_e;

typedef struct motor_info {
    uint8_t motor_num;
    uint8_t seq_index;
    uint8_t dir;
    uint8_t sign_sta;
    uint32_t cur_step_num;
    uint32_t target_step_num;
    motor_mode_e work_mode;
    motor_mode_e idle_mode;
    uint8_t freq_div;
} motor_info_t;

void robot_init(motor_sign_write_func func);
void robot_goto_target(motor_name_e motor_num, uint32_t target);
void robot_run_tick(void);
motor_info_t *get_motor_list(void);

#endif
